package com.systemsetup.systemsetup.web.web;

import cn.hutool.json.JSONObject;
import com.systemsetup.systemsetup.common.base.BaseController;
import com.systemsetup.systemsetup.support.annotaion.Action;
import com.systemsetup.systemsetup.support.model.RespEntity;
import com.systemsetup.systemsetup.web.service.OrganizationTreeListService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.Map;


/**
 * 机构树形菜单控制
 * @author Yang
 */
@Action
@RequestMapping("systemsetup")
public class OrganizationTreeListController extends BaseController {

    @Resource
    private OrganizationTreeListService orgAndDeptsTreeList;

    /**
     * 机构树形菜单接口
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/orgTreeList",method = RequestMethod.GET)
        public RespEntity orgAndDeptsTreeList(@RequestBody(required = false) JSONObject jsonParam) {
        return orgAndDeptsTreeList.orgTreeList(jsonParam);
    }
    /**
     * 根据机构id查询所有的父id接口
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/getorgAllListId",method = RequestMethod.POST)
    public RespEntity getorgAllListId(@RequestBody(required = false) JSONObject jsonParam) {
        return orgAndDeptsTreeList.getorgAllListId(jsonParam);
    }

    /**
     * 查询所有的机构id
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/getOrganizationsId",method = RequestMethod.POST)
    public RespEntity getOrganizationsId(@RequestBody(required = false) JSONObject jsonParam) {
        return orgAndDeptsTreeList.getOrganizationsId(jsonParam);
    }

    /**
     * 导入时用的机构id
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/getOrganizationListId",method = RequestMethod.GET)
    public RespEntity getOrganizationListId(@RequestBody(required = false) JSONObject jsonParam) {
        return orgAndDeptsTreeList.getOrganizationListId(jsonParam);
    }
    /**
     * 根据机构id查询所有的父id接口(不带Token)
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/getOrgAllId",method = RequestMethod.POST)
    public RespEntity getOrgAllId(@RequestBody(required = false) JSONObject jsonParam) {
        return orgAndDeptsTreeList.getOrgAllId(jsonParam);
    }
    /**
     * 机构删除
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/orgDelete",method = RequestMethod.POST)
    public RespEntity orgDelete(@RequestBody(required = false) JSONObject jsonParam) {
        return orgAndDeptsTreeList.orgDelete(jsonParam);
    }

    /**
     * 机构新增
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/orgAdd",method = RequestMethod.POST)
    public RespEntity orgAdd(@RequestBody(required = false) JSONObject jsonParam) {
        return orgAndDeptsTreeList.orgAdd(jsonParam);
    }

    /**
     * 机构修改
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/orgUpdate",method = RequestMethod.POST)
    public RespEntity orgUpdate(@RequestBody(required = false) JSONObject jsonParam) {
        return orgAndDeptsTreeList.orgUpdate(jsonParam);
    }

    /**
     * 机构详情
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/orgDetail",method = RequestMethod.GET)
    public RespEntity orgDetail(@RequestBody(required = false) JSONObject jsonParam) {
        return orgAndDeptsTreeList.orgDetail(jsonParam);
    }

    /**
     * 设备导入时调用
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/getAllOrgIdList",method = RequestMethod.POST)
    public Map<String, Object> getAllOrgIdList(@RequestParam Map<String, Object> jsonParam) {
        return orgAndDeptsTreeList.getAllOrgIdList(jsonParam);
    }
    /**
     * 机构列表
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/getOrgList")
    public RespEntity getOrgList(@RequestBody(required = false) JSONObject jsonParam) {
        return orgAndDeptsTreeList.getOrgList(jsonParam);
    }
    /**
     * @Author YangYu
     * @Description 根据父级ID获取机构
     * @Date Created in 13:29 2023/6/2
     * @Param [jsonParam]
     */

    @RequestMapping(value = "/getPidOrgList")
    public RespEntity getPidOrgList(@RequestBody(required = false) JSONObject jsonParam) {
        return orgAndDeptsTreeList.getPidOrgList(jsonParam);
    }

    /**
     * 获取本机及下级的机构id
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/getOrgIdAndDownOrgIds",method = RequestMethod.GET)
    public RespEntity getOrgIdAndDownOrgIds(@RequestBody(required = false) JSONObject jsonParam) {
        return orgAndDeptsTreeList.getOrgIdAndDownOrgIds(jsonParam);
    }

    /**
     * 获取本机及下级的机构id
     * @param jsonParam
     * @return
     */
    @RequestMapping(value = "/washData",method = RequestMethod.POST)
    public RespEntity washData(@RequestBody(required = false) JSONObject jsonParam) {
        return orgAndDeptsTreeList.washData(jsonParam);
    }
}
